﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web
{
    public partial class WebAddressEdit : FromentWebCommon
    {
        public Model.tb_address model = new Model.tb_address();
        public int uid = 0;
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (!Page.IsPostBack)
            {
                if (string.IsNullOrEmpty(Common.UICookie.ReadCookie("ClientUId")))
                {
                    Response.Write("<script>alert('请先登录！');window.location.href='default.aspx';</script>");
                }
                else
                {
                    int cid = Convert.ToInt32(Common.UICookie.ReadCookie("ClientUId"));
                    uid = cid;
                    if (Request.QueryString["Id"] != null)
                    {
                        int Id = 0;
                        if (int.TryParse(Request.QueryString["Id"], out Id))
                        {
                            GetModel(Id);
                        }
                    }
                }
              
            }
         
        }
        public void GetModel(int Id)
        {
            Model.tb_address data = Common.SqlExption.GetList<Model.tb_address>().FirstOrDefault(c => c.Id.Equals(Id));
             var umodel = Common.SqlExption.GetList<Model.tb_user>().FirstOrDefault(c => c.Id.Equals(uid));

            if (data != null)
            {
                model = data;
            }
            else
            {
                model.Id = 0;
                model.user_number = umodel.user_number;
            }



        }
    }
}